{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<!--BOOK_INFORMATION-->\n",
    "<a href=\"https://user-images.githubusercontent.com/19553554/71825144-2d568180-30d6-11ea-8ee0-63c849cfd934.png\" target=\"_blank\"><img align=\"left\" style=\"width: 76px; height: 100px; background: white; padding: 1px; border: 1px solid black; margin-right:10px;\"></a>\n",
    "*pyecharts 是一个用于生成 Echarts 图表的类库。Echarts 是百度开源的一个数据可视化 JS 库。用 Echarts 生成的图可视化效果非常棒，为了与 Python 进行对接，方便在 Python 中直接使用数据生成图，于是有人开发出了这个项目[GitHub](https://github.com/pyecharts/pyecharts) .*\n",
    "\n",
    "*Note.建议本程序在参看https://github.com/pyecharts/pyecharts 的安装步骤后再运行； 本程序所有的例子都是从官方提供的样例代码[GitHub](https://github.com/pyecharts/pyecharts-gallery)中提取的,如果对某个API有疑问建议在IDE里面查看*\n",
    "\n",
    "*Echart类型图种大全:https://echarts.apache.org/examples/zh/#chart-type-line pyecharts图导入到ppt中的方法:https://baijiahao.baidu.com/s?id=1663839456876951842&wfr=spider&for=pc.*\n",
    "\n",
    "*作者: LBQ; 时间:2020/7/24. 邮箱:779660843@qq.com*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# XXVI.饼图(Pie)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"31b635ebeb294fd5aab2a96d73a97643\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_31b635ebeb294fd5aab2a96d73a97643 = echarts.init(\n",
       "                    document.getElementById('31b635ebeb294fd5aab2a96d73a97643'), 'white', {renderer: 'canvas'});\n",
       "                var option_31b635ebeb294fd5aab2a96d73a97643 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u4e00\",\n",
       "                    \"value\": 140\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u4e8c\",\n",
       "                    \"value\": 55\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u4e09\",\n",
       "                    \"value\": 67\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u56db\",\n",
       "                    \"value\": 53\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u4e94\",\n",
       "                    \"value\": 62\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u516d\",\n",
       "                    \"value\": 44\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u65e5\",\n",
       "                    \"value\": 88\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5468\\u4e00\",\n",
       "                \"\\u5468\\u4e8c\",\n",
       "                \"\\u5468\\u4e09\",\n",
       "                \"\\u5468\\u56db\",\n",
       "                \"\\u5468\\u4e94\",\n",
       "                \"\\u5468\\u516d\",\n",
       "                \"\\u5468\\u65e5\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Pie-\\u57fa\\u672c\\u793a\\u4f8b\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_31b635ebeb294fd5aab2a96d73a97643.setOption(option_31b635ebeb294fd5aab2a96d73a97643);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f4047655710>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\"\", [list(z) for z in zip(Faker.choose(), Faker.values())])\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Pie-基本示例\"))\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c.load_javascript()\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"a4c3c068991e4f208c7d089238203b6e\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_a4c3c068991e4f208c7d089238203b6e = echarts.init(\n",
       "                    document.getElementById('a4c3c068991e4f208c7d089238203b6e'), 'white', {renderer: 'canvas'});\n",
       "                var option_a4c3c068991e4f208c7d089238203b6e = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u4e00\",\n",
       "                    \"value\": 140\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u4e8c\",\n",
       "                    \"value\": 55\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u4e09\",\n",
       "                    \"value\": 67\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u56db\",\n",
       "                    \"value\": 53\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u4e94\",\n",
       "                    \"value\": 62\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u516d\",\n",
       "                    \"value\": 44\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5468\\u65e5\",\n",
       "                    \"value\": 88\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5468\\u4e00\",\n",
       "                \"\\u5468\\u4e8c\",\n",
       "                \"\\u5468\\u4e09\",\n",
       "                \"\\u5468\\u56db\",\n",
       "                \"\\u5468\\u4e94\",\n",
       "                \"\\u5468\\u516d\",\n",
       "                \"\\u5468\\u65e5\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Pie-\\u57fa\\u672c\\u793a\\u4f8b\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_a4c3c068991e4f208c7d089238203b6e.setOption(option_a4c3c068991e4f208c7d089238203b6e);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f405c18a0f0>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Pie\n",
    "\n",
    "\"\"\"\n",
    "Gallery 使用 pyecharts 1.1.0\n",
    "参考地址: https://echarts.baidu.com/examples/editor.html?c=pie-doughnut\n",
    "\n",
    "目前无法实现的功能:\n",
    "\n",
    "1、迷之颜色映射的问题\n",
    "\"\"\"\n",
    "\n",
    "x_data = [\"直接访问\", \"邮件营销\", \"联盟广告\", \"视频广告\", \"搜索引擎\"]\n",
    "y_data = [335, 310, 274, 235, 400]\n",
    "data_pair = [list(z) for z in zip(x_data, y_data)]\n",
    "data_pair.sort(key=lambda x: x[1])\n",
    "\n",
    "(\n",
    "    Pie(init_opts=opts.InitOpts(bg_color=\"#2c343c\"))\n",
    "    .add(\n",
    "        series_name=\"访问来源\",\n",
    "        data_pair=data_pair,\n",
    "        rosetype=\"radius\",\n",
    "        radius=\"55%\",\n",
    "        center=[\"50%\", \"50%\"],\n",
    "        label_opts=opts.LabelOpts(is_show=False, position=\"center\"),\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title=\"Customized Pie\",\n",
    "            pos_left=\"center\",\n",
    "            pos_top=\"20\",\n",
    "            title_textstyle_opts=opts.TextStyleOpts(color=\"#fff\"),\n",
    "        ),\n",
    "        legend_opts=opts.LegendOpts(is_show=False),\n",
    "    )\n",
    "    .set_series_opts(\n",
    "        tooltip_opts=opts.TooltipOpts(\n",
    "            trigger=\"item\", formatter=\"{a} <br/>{b}: {c} ({d}%)\"\n",
    "        ),\n",
    "        label_opts=opts.LabelOpts(color=\"rgba(255, 255, 255, 0.3)\"),\n",
    "    )\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c.load_javascript()\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"b8904880e05f49dd9fc9833d16744d55\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_b8904880e05f49dd9fc9833d16744d55 = echarts.init(\n",
       "                    document.getElementById('b8904880e05f49dd9fc9833d16744d55'), 'white', {renderer: 'canvas'});\n",
       "                var option_b8904880e05f49dd9fc9833d16744d55 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u8bbf\\u95ee\\u6765\\u6e90\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u76f4\\u63a5\\u8bbf\\u95ee\",\n",
       "                    \"value\": 335\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u90ae\\u4ef6\\u8425\\u9500\",\n",
       "                    \"value\": 310\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8054\\u76df\\u5e7f\\u544a\",\n",
       "                    \"value\": 234\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u89c6\\u9891\\u5e7f\\u544a\",\n",
       "                    \"value\": 135\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u641c\\u7d22\\u5f15\\u64ce\",\n",
       "                    \"value\": 1548\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"50%\",\n",
       "                \"70%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"center\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b}: {c} ({d}%)\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u76f4\\u63a5\\u8bbf\\u95ee\",\n",
       "                \"\\u90ae\\u4ef6\\u8425\\u9500\",\n",
       "                \"\\u8054\\u76df\\u5e7f\\u544a\",\n",
       "                \"\\u89c6\\u9891\\u5e7f\\u544a\",\n",
       "                \"\\u641c\\u7d22\\u5f15\\u64ce\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"left\": \"legft\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_b8904880e05f49dd9fc9833d16744d55.setOption(option_b8904880e05f49dd9fc9833d16744d55);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f4047605438>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Pie\n",
    "\n",
    "\"\"\"\n",
    "Gallery 使用 pyecharts 1.1.0\n",
    "参考地址: https://echarts.baidu.com/examples/editor.html?c=pie-doughnut\n",
    "\n",
    "目前无法实现的功能:\n",
    "\n",
    "1、饼状图中间的图例名称暂时无法显示\n",
    "\"\"\"\n",
    "\n",
    "x_data = [\"直接访问\", \"邮件营销\", \"联盟广告\", \"视频广告\", \"搜索引擎\"]\n",
    "y_data = [335, 310, 234, 135, 1548]\n",
    "\n",
    "wy = (\n",
    "    Pie()\n",
    "    .add(\n",
    "        series_name=\"访问来源\",\n",
    "        data_pair=[list(z) for z in zip(x_data, y_data)],\n",
    "        radius=[\"50%\", \"70%\"],\n",
    "        label_opts=opts.LabelOpts(is_show=False, position=\"center\"),\n",
    "    )\n",
    "    .set_global_opts(legend_opts=opts.LegendOpts(pos_left=\"legft\", orient=\"vertical\"))\n",
    "    .set_series_opts(\n",
    "        tooltip_opts=opts.TooltipOpts(\n",
    "            trigger=\"item\", formatter=\"{a} <br/>{b}: {c} ({d}%)\"\n",
    "        ),\n",
    "        # label_opts=opts.LabelOpts(formatter=\"{b}: {c}\")\n",
    "    )\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "wy.load_javascript()\n",
    "wy.render_notebook()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"9cc656a30bc24838a65ffd28850c1d70\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_9cc656a30bc24838a65ffd28850c1d70 = echarts.init(\n",
       "                    document.getElementById('9cc656a30bc24838a65ffd28850c1d70'), 'white', {renderer: 'canvas'});\n",
       "                var option_9cc656a30bc24838a65ffd28850c1d70 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5267\\u60c5\",\n",
       "                    \"value\": 25\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 75\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                60,\n",
       "                80\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"20%\",\n",
       "                \"30%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"center\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\":     function(params) {        if(params.name == '\\u5176\\u4ed6')            return '\\n\\n\\n' + params.name + ' : ' + params.value + '%';        return params.name + ' : ' + params.value + '%';    }    \n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5947\\u5e7b\",\n",
       "                    \"value\": 24\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 76\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                60,\n",
       "                80\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"55%\",\n",
       "                \"30%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"center\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\":     function(params) {        if(params.name == '\\u5176\\u4ed6')            return '\\n\\n\\n' + params.name + ' : ' + params.value + '%';        return params.name + ' : ' + params.value + '%';    }    \n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u7231\\u60c5\",\n",
       "                    \"value\": 14\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 86\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                60,\n",
       "                80\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"20%\",\n",
       "                \"70%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"center\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\":     function(params) {        if(params.name == '\\u5176\\u4ed6')            return '\\n\\n\\n' + params.name + ' : ' + params.value + '%';        return params.name + ' : ' + params.value + '%';    }    \n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u60ca\\u609a\",\n",
       "                    \"value\": 11\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 89\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                60,\n",
       "                80\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"55%\",\n",
       "                \"70%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"center\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\":     function(params) {        if(params.name == '\\u5176\\u4ed6')            return '\\n\\n\\n' + params.name + ' : ' + params.value + '%';        return params.name + ' : ' + params.value + '%';    }    \n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5267\\u60c5\",\n",
       "                \"\\u5176\\u4ed6\",\n",
       "                \"\\u5947\\u5e7b\",\n",
       "                \"\\u7231\\u60c5\",\n",
       "                \"\\u60ca\\u609a\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"type\": \"scroll\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"80%\",\n",
       "            \"top\": \"20%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Pie-\\u591a\\u997c\\u56fe\\u57fa\\u672c\\u793a\\u4f8b\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_9cc656a30bc24838a65ffd28850c1d70.setOption(option_9cc656a30bc24838a65ffd28850c1d70);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f40476559e8>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts.commons.utils import JsCode\n",
    "\n",
    "\n",
    "fn = \"\"\"\n",
    "    function(params) {\n",
    "        if(params.name == '其他')\n",
    "            return '\\\\n\\\\n\\\\n' + params.name + ' : ' + params.value + '%';\n",
    "        return params.name + ' : ' + params.value + '%';\n",
    "    }\n",
    "    \"\"\"\n",
    "\n",
    "\n",
    "def new_label_opts():\n",
    "    return opts.LabelOpts(formatter=JsCode(fn), position=\"center\")\n",
    "\n",
    "\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\n",
    "        \"\",\n",
    "        [list(z) for z in zip([\"剧情\", \"其他\"], [25, 75])],\n",
    "        center=[\"20%\", \"30%\"],\n",
    "        radius=[60, 80],\n",
    "        label_opts=new_label_opts(),\n",
    "    )\n",
    "    .add(\n",
    "        \"\",\n",
    "        [list(z) for z in zip([\"奇幻\", \"其他\"], [24, 76])],\n",
    "        center=[\"55%\", \"30%\"],\n",
    "        radius=[60, 80],\n",
    "        label_opts=new_label_opts(),\n",
    "    )\n",
    "    .add(\n",
    "        \"\",\n",
    "        [list(z) for z in zip([\"爱情\", \"其他\"], [14, 86])],\n",
    "        center=[\"20%\", \"70%\"],\n",
    "        radius=[60, 80],\n",
    "        label_opts=new_label_opts(),\n",
    "    )\n",
    "    .add(\n",
    "        \"\",\n",
    "        [list(z) for z in zip([\"惊悚\", \"其他\"], [11, 89])],\n",
    "        center=[\"55%\", \"70%\"],\n",
    "        radius=[60, 80],\n",
    "        label_opts=new_label_opts(),\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"Pie-多饼图基本示例\"),\n",
    "        legend_opts=opts.LegendOpts(\n",
    "            type_=\"scroll\", pos_top=\"20%\", pos_left=\"80%\", orient=\"vertical\"\n",
    "        ),\n",
    "    )\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c.load_javascript()\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 嵌套格式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"dc0421507f694059b4e9202574929039\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_dc0421507f694059b4e9202574929039 = echarts.init(\n",
       "                    document.getElementById('dc0421507f694059b4e9202574929039'), 'white', {renderer: 'canvas'});\n",
       "                var option_dc0421507f694059b4e9202574929039 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u8bbf\\u95ee\\u6765\\u6e90\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u76f4\\u8fbe\",\n",
       "                    \"value\": 335\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8425\\u9500\\u5e7f\\u544a\",\n",
       "                    \"value\": 679\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u641c\\u7d22\\u5f15\\u64ce\",\n",
       "                    \"value\": 1548\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                0,\n",
       "                \"30%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inner\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b}: {c} ({d}%)\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u8bbf\\u95ee\\u6765\\u6e90\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u76f4\\u8fbe\",\n",
       "                    \"value\": 335\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8425\\u9500\\u5e7f\\u544a\",\n",
       "                    \"value\": 310\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u641c\\u7d22\\u5f15\\u64ce\",\n",
       "                    \"value\": 234\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u90ae\\u4ef6\\u8425\\u9500\",\n",
       "                    \"value\": 135\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8054\\u76df\\u5e7f\\u544a\",\n",
       "                    \"value\": 1048\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u89c6\\u9891\\u5e7f\\u544a\",\n",
       "                    \"value\": 251\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u767e\\u5ea6\",\n",
       "                    \"value\": 147\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8c37\\u6b4c\",\n",
       "                    \"value\": 102\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"40%\",\n",
       "                \"55%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"outside\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{a|{a}}{abg|}\\n{hr|}\\n {b|{b}: }{c}  {per|{d}%}  \",\n",
       "                \"backgroundColor\": \"#eee\",\n",
       "                \"borderColor\": \"#aaa\",\n",
       "                \"borderWidth\": 1,\n",
       "                \"borderRadius\": 4,\n",
       "                \"rich\": {\n",
       "                    \"a\": {\n",
       "                        \"color\": \"#999\",\n",
       "                        \"lineHeight\": 22,\n",
       "                        \"align\": \"center\"\n",
       "                    },\n",
       "                    \"abg\": {\n",
       "                        \"backgroundColor\": \"#e3e3e3\",\n",
       "                        \"width\": \"100%\",\n",
       "                        \"align\": \"right\",\n",
       "                        \"height\": 22,\n",
       "                        \"borderRadius\": [\n",
       "                            4,\n",
       "                            4,\n",
       "                            0,\n",
       "                            0\n",
       "                        ]\n",
       "                    },\n",
       "                    \"hr\": {\n",
       "                        \"borderColor\": \"#aaa\",\n",
       "                        \"width\": \"100%\",\n",
       "                        \"borderWidth\": 0.5,\n",
       "                        \"height\": 0\n",
       "                    },\n",
       "                    \"b\": {\n",
       "                        \"fontSize\": 16,\n",
       "                        \"lineHeight\": 33\n",
       "                    },\n",
       "                    \"per\": {\n",
       "                        \"color\": \"#eee\",\n",
       "                        \"backgroundColor\": \"#334455\",\n",
       "                        \"padding\": [\n",
       "                            2,\n",
       "                            4\n",
       "                        ],\n",
       "                        \"borderRadius\": 2\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b}: {c} ({d}%)\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u76f4\\u8fbe\",\n",
       "                \"\\u8425\\u9500\\u5e7f\\u544a\",\n",
       "                \"\\u641c\\u7d22\\u5f15\\u64ce\",\n",
       "                \"\\u90ae\\u4ef6\\u8425\\u9500\",\n",
       "                \"\\u8054\\u76df\\u5e7f\\u544a\",\n",
       "                \"\\u89c6\\u9891\\u5e7f\\u544a\",\n",
       "                \"\\u767e\\u5ea6\",\n",
       "                \"\\u8c37\\u6b4c\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"left\": \"left\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_dc0421507f694059b4e9202574929039.setOption(option_dc0421507f694059b4e9202574929039);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f4047605940>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Pie\n",
    "\n",
    "\"\"\"\n",
    "Gallery 使用 pyecharts 1.1.0\n",
    "参考地址: https://echarts.baidu.com/examples/editor.html?c=pie-nest\n",
    "\n",
    "目前无法实现的功能:\n",
    "\n",
    "1、暂无\n",
    "\"\"\"\n",
    "\n",
    "inner_x_data = [\"直达\", \"营销广告\", \"搜索引擎\"]\n",
    "inner_y_data = [335, 679, 1548]\n",
    "inner_data_pair = [list(z) for z in zip(inner_x_data, inner_y_data)]\n",
    "\n",
    "outer_x_data = [\"直达\", \"营销广告\", \"搜索引擎\", \"邮件营销\", \"联盟广告\", \"视频广告\", \"百度\", \"谷歌\", \"必应\", \"其他\"]\n",
    "outer_y_data = [335, 310, 234, 135, 1048, 251, 147, 102]\n",
    "outer_data_pair = [list(z) for z in zip(outer_x_data, outer_y_data)]\n",
    "\n",
    "c2 = (\n",
    "    Pie()\n",
    "    .add(\n",
    "        series_name=\"访问来源\",\n",
    "        data_pair=inner_data_pair,\n",
    "        radius=[0, \"30%\"],\n",
    "        label_opts=opts.LabelOpts(position=\"inner\"),\n",
    "    )\n",
    "    .add(\n",
    "        series_name=\"访问来源\",\n",
    "        radius=[\"40%\", \"55%\"],\n",
    "        data_pair=outer_data_pair,\n",
    "        label_opts=opts.LabelOpts(\n",
    "            position=\"outside\",\n",
    "            formatter=\"{a|{a}}{abg|}\\n{hr|}\\n {b|{b}: }{c}  {per|{d}%}  \",\n",
    "            background_color=\"#eee\",\n",
    "            border_color=\"#aaa\",\n",
    "            border_width=1,\n",
    "            border_radius=4,\n",
    "            rich={\n",
    "                \"a\": {\"color\": \"#999\", \"lineHeight\": 22, \"align\": \"center\"},\n",
    "                \"abg\": {\n",
    "                    \"backgroundColor\": \"#e3e3e3\",\n",
    "                    \"width\": \"100%\",\n",
    "                    \"align\": \"right\",\n",
    "                    \"height\": 22,\n",
    "                    \"borderRadius\": [4, 4, 0, 0],\n",
    "                },\n",
    "                \"hr\": {\n",
    "                    \"borderColor\": \"#aaa\",\n",
    "                    \"width\": \"100%\",\n",
    "                    \"borderWidth\": 0.5,\n",
    "                    \"height\": 0,\n",
    "                },\n",
    "                \"b\": {\"fontSize\": 16, \"lineHeight\": 33},\n",
    "                \"per\": {\n",
    "                    \"color\": \"#eee\",\n",
    "                    \"backgroundColor\": \"#334455\",\n",
    "                    \"padding\": [2, 4],\n",
    "                    \"borderRadius\": 2,\n",
    "                },\n",
    "            },\n",
    "        ),\n",
    "    )\n",
    "    .set_global_opts(legend_opts=opts.LegendOpts(pos_left=\"left\", orient=\"vertical\"))\n",
    "    .set_series_opts(\n",
    "        tooltip_opts=opts.TooltipOpts(\n",
    "            trigger=\"item\", formatter=\"{a} <br/>{b}: {c} ({d}%)\"\n",
    "        )\n",
    "    )\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c2.load_javascript()\n",
    "c2.render_notebook()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 滚动格式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"e75ff3d5969f43bab96915a3591ff0bd\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_e75ff3d5969f43bab96915a3591ff0bd = echarts.init(\n",
       "                    document.getElementById('e75ff3d5969f43bab96915a3591ff0bd'), 'white', {renderer: 'canvas'});\n",
       "                var option_e75ff3d5969f43bab96915a3591ff0bd = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5c0f\\u7c73\",\n",
       "                    \"value\": 115\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e09\\u661f\",\n",
       "                    \"value\": 107\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u534e\\u4e3a\",\n",
       "                    \"value\": 53\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u82f9\\u679c\",\n",
       "                    \"value\": 146\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9b45\\u65cf\",\n",
       "                    \"value\": 45\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"VIVO\",\n",
       "                    \"value\": 51\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"OPPO\",\n",
       "                    \"value\": 62\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c0f\\u7c73\",\n",
       "                    \"value\": 137\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e09\\u661f\",\n",
       "                    \"value\": 20\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u534e\\u4e3a\",\n",
       "                    \"value\": 100\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u82f9\\u679c\",\n",
       "                    \"value\": 25\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9b45\\u65cf\",\n",
       "                    \"value\": 97\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"VIVO\",\n",
       "                    \"value\": 127\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"OPPO\",\n",
       "                    \"value\": 42\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8349\\u8393\",\n",
       "                    \"value\": 45\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8292\\u679c\",\n",
       "                    \"value\": 133\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8461\\u8404\",\n",
       "                    \"value\": 74\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u96ea\\u68a8\",\n",
       "                    \"value\": 45\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u74dc\",\n",
       "                    \"value\": 142\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u67e0\\u6aac\",\n",
       "                    \"value\": 106\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8f66\\u5398\\u5b50\",\n",
       "                    \"value\": 36\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"40%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c73\",\n",
       "                \"\\u4e09\\u661f\",\n",
       "                \"\\u534e\\u4e3a\",\n",
       "                \"\\u82f9\\u679c\",\n",
       "                \"\\u9b45\\u65cf\",\n",
       "                \"VIVO\",\n",
       "                \"OPPO\",\n",
       "                \"\\u8349\\u8393\",\n",
       "                \"\\u8292\\u679c\",\n",
       "                \"\\u8461\\u8404\",\n",
       "                \"\\u96ea\\u68a8\",\n",
       "                \"\\u897f\\u74dc\",\n",
       "                \"\\u67e0\\u6aac\",\n",
       "                \"\\u8f66\\u5398\\u5b50\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"type\": \"scroll\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"80%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Pie-Legend \\u6eda\\u52a8\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_e75ff3d5969f43bab96915a3591ff0bd.setOption(option_e75ff3d5969f43bab96915a3591ff0bd);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f4047635470>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "c3 = (\n",
    "    Pie()\n",
    "    .add(\n",
    "        \"\",\n",
    "        [\n",
    "            list(z)\n",
    "            for z in zip(\n",
    "                Faker.choose() + Faker.choose() + Faker.choose(),\n",
    "                Faker.values() + Faker.values() + Faker.values(),\n",
    "            )\n",
    "        ],\n",
    "        center=[\"40%\", \"50%\"],\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"Pie-Legend 滚动\"),\n",
    "        legend_opts=opts.LegendOpts(type_=\"scroll\", pos_left=\"80%\", orient=\"vertical\"),\n",
    "    )\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c3.load_javascript()\n",
    "c3.render_notebook()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 其它设定"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"b27dded0a4004dae87969b68c1189282\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_b27dded0a4004dae87969b68c1189282 = echarts.init(\n",
       "                    document.getElementById('b27dded0a4004dae87969b68c1189282'), 'white', {renderer: 'canvas'});\n",
       "                var option_b27dded0a4004dae87969b68c1189282 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"blue\",\n",
       "        \"green\",\n",
       "        \"yellow\",\n",
       "        \"red\",\n",
       "        \"pink\",\n",
       "        \"orange\",\n",
       "        \"purple\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5c0f\\u7c73\",\n",
       "                    \"value\": 34\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e09\\u661f\",\n",
       "                    \"value\": 63\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u534e\\u4e3a\",\n",
       "                    \"value\": 140\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u82f9\\u679c\",\n",
       "                    \"value\": 92\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9b45\\u65cf\",\n",
       "                    \"value\": 85\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"VIVO\",\n",
       "                    \"value\": 137\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"OPPO\",\n",
       "                    \"value\": 71\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5c0f\\u7c73\",\n",
       "                \"\\u4e09\\u661f\",\n",
       "                \"\\u534e\\u4e3a\",\n",
       "                \"\\u82f9\\u679c\",\n",
       "                \"\\u9b45\\u65cf\",\n",
       "                \"VIVO\",\n",
       "                \"OPPO\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Pie-\\u8bbe\\u7f6e\\u989c\\u8272\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_b27dded0a4004dae87969b68c1189282.setOption(option_b27dded0a4004dae87969b68c1189282);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f4047635748>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c4 = (\n",
    "    Pie()\n",
    "    .add(\"\", [list(z) for z in zip(Faker.choose(), Faker.values())])\n",
    "    .set_colors([\"blue\", \"green\", \"yellow\", \"red\", \"pink\", \"orange\", \"purple\"])\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Pie-设置颜色\"))\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c4.load_javascript()\n",
    "c4.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  玫瑰图示例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fisadm/anaconda3/envs/detectron2/lib/python3.7/site-packages/pyecharts/charts/chart.py:14: PendingDeprecationWarning: pyecharts 所有图表类型将在 v1.9.0 版本开始强制使用 ChartItem 进行数据项配置 :)\n",
      "  super().__init__(init_opts=init_opts)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"fd7c42bfb14646c6827773fe133f2b46\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_fd7c42bfb14646c6827773fe133f2b46 = echarts.init(\n",
       "                    document.getElementById('fd7c42bfb14646c6827773fe133f2b46'), 'white', {renderer: 'canvas'});\n",
       "                var option_fd7c42bfb14646c6827773fe133f2b46 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u8349\\u8393\",\n",
       "                    \"value\": 96\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8292\\u679c\",\n",
       "                    \"value\": 130\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8461\\u8404\",\n",
       "                    \"value\": 39\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u96ea\\u68a8\",\n",
       "                    \"value\": 100\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u74dc\",\n",
       "                    \"value\": 110\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u67e0\\u6aac\",\n",
       "                    \"value\": 122\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8f66\\u5398\\u5b50\",\n",
       "                    \"value\": 114\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"30%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"25%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"roseType\": \"radius\",\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u8349\\u8393\",\n",
       "                    \"value\": 52\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8292\\u679c\",\n",
       "                    \"value\": 114\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8461\\u8404\",\n",
       "                    \"value\": 45\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u96ea\\u68a8\",\n",
       "                    \"value\": 71\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u74dc\",\n",
       "                    \"value\": 73\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u67e0\\u6aac\",\n",
       "                    \"value\": 133\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8f66\\u5398\\u5b50\",\n",
       "                    \"value\": 67\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"30%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"75%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"roseType\": \"area\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8349\\u8393\",\n",
       "                \"\\u8292\\u679c\",\n",
       "                \"\\u8461\\u8404\",\n",
       "                \"\\u96ea\\u68a8\",\n",
       "                \"\\u897f\\u74dc\",\n",
       "                \"\\u67e0\\u6aac\",\n",
       "                \"\\u8f66\\u5398\\u5b50\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Pie-\\u73ab\\u7470\\u56fe\\u793a\\u4f8b\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_fd7c42bfb14646c6827773fe133f2b46.setOption(option_fd7c42bfb14646c6827773fe133f2b46);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x7f40475dca58>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "v = Faker.choose()\n",
    "c5 = (\n",
    "    Pie()\n",
    "    .add(\n",
    "        \"\",\n",
    "        [list(z) for z in zip(v, Faker.values())],\n",
    "        radius=[\"30%\", \"75%\"],\n",
    "        center=[\"25%\", \"50%\"],\n",
    "        rosetype=\"radius\",\n",
    "        label_opts=opts.LabelOpts(is_show=False),\n",
    "    )\n",
    "    .add(\n",
    "        \"\",\n",
    "        [list(z) for z in zip(v, Faker.values())],\n",
    "        radius=[\"30%\", \"75%\"],\n",
    "        center=[\"75%\", \"50%\"],\n",
    "        rosetype=\"area\",\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Pie-玫瑰图示例\"))\n",
    "    #.render(\"map3d_china_base.html\")\n",
    ")\n",
    "c5.load_javascript()\n",
    "c5.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
